package com.lrkj.web.phone;

import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.core.page.TableDataInfo;
import com.lrkj.smartservice.domain.PressInfo;
import com.lrkj.smartservice.domain.PressType;
import com.lrkj.smartservice.service.IPressInfoService;
import com.lrkj.smartservice.service.IPressTypeService;
import com.lrkj.smartservice.service.ISlideDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "手机端服务信息")
public class SmartServiceController extends BaseController {

    @Autowired
    private IPressInfoService pressInfoService;

    @Autowired
    private ISlideDataService slideDataService;

    @Autowired
    private IPressTypeService pressTypeService;


    @ApiOperation(value = "查询信息分类列表", notes = "查询信息分类列表")
    @GetMapping("/phone/pressType/list")
    public TableDataInfo pressTypeList(PressType pressType)
    {
        startPage();
        List<PressType> list = pressTypeService.selectPressTypeList(pressType);
        return getDataTable(list);
    }


    /**
     * 查询新闻管理列表
     */
    @ApiOperation(value = "查询新闻管理列表", notes = "查询新闻管理列表")
    @GetMapping("/phone/pressInfo/list")
    public TableDataInfo list(PressInfo pressInfo) {
        startPage();
        List<PressInfo> list = pressInfoService.selectPressInfoList(pressInfo);
        return getDataTable(list);
    }

    /**
     * 获取新闻管理详细信息
     */
    @ApiOperation(value = "获取新闻管理详细信息", notes = "获取新闻管理详细信息")
    @GetMapping(value = "/phone/pressInfo/{pressInfoId}")
    public AjaxResult getInfo(@PathVariable("pressInfoId") String pressInfoId) {
        return AjaxResult.success(pressInfoService.selectPressInfoById(pressInfoId));
    }

    /**
     * 更新查阅次数
     */
    @ApiOperation(value = "更新查阅次数", notes = "更新查阅次数")
    @PostMapping(value = "/phone/pressInfo/updatePageView")
    public AjaxResult updatePageView(@RequestBody PressInfo pressInfo) {
        return toAjax(pressInfoService.updatePageView(pressInfo));
    }

    /**
     * 根据轮播类型查询列表信息
     */
    @ApiOperation(value = "根据轮播类型查询列表信息", notes = "根据轮播类型查询列表信息")
    @GetMapping(value = "/phone/slideData/{slideType}")
    public AjaxResult dictType(@PathVariable String slideType)
    {
        return AjaxResult.success(slideDataService.selectSlideDataByType(slideType));
    }


}
